<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>因子看板</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="description" content="聚宽让量化交易的成长之路更为平坦，聚宽让做量化交易的成本极大降低">
    <meta name="keywords" content="因子看板、研究策略、本地数据、量化聚宽">
    <meta name="robots" content="all"/>
    <link rel="shortcut icon" href="../static/favicon.ico"  type="image/x-icon"/>
    <link rel="stylesheet" href="../static/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/public.css">
    <link rel="stylesheet" href="../static/css/index.css">
    <script src="../static/jquery-1.11.1.min.js"></script>
    <script src="../static/echarts/dist/echarts.min.js"></script>
    <script src="../static/layui/layui.js"></script>
</head>
<body>
  <!-- 头部 -->
  <div class="head">
    <span class="logo">AI因子看板</span>
    <ul class="layui-nav first">
      <li class="layui-nav-item" onclick="showmodel()">专家信息</li>
      <li class="layui-nav-item" onclick="showmodel()">园区信息</li>
      <li class="layui-nav-item"><a href="/ccrs">自助评级</a></li>
      <li class="layui-nav-item"><a href="http://ipoipo.cn/">行业研究</a></li>
      <li class="layui-nav-item"><a href="https://bigquant.com/wiki/home">量化研究</a></li>
      <li class="layui-nav-item"><a target="_blank" href="http://www.chaguwang.cn/">查股网</a></li>
      <li class="layui-nav-item"><a href="/">首页</a></li>
      <li><a href="/search" class="layui-icon" style="color: #ffffff;">&#xe615;</a></li>
    </ul>
    <ul class="sec">
      <li class="layui-nav-item two_li">
        <i class="layui-icon" style="padding: 0 0 0 20px;">&#xe671;</i>
        <dl class="layui-nav-child">
          <dd><a href="/search"><i class="layui-icon" class="">&#xe615;</i></a></dd>
          <dd><a href="/">首页</a></dd>
          <dd><a target="_blank" href="http://www.chaguwang.cn/">查股网</a></dd>
          <dd><a href="https://bigquant.com/wiki/home">量化研究</a></dd>
          <dd><a href="http://ipoipo.cn/">行业研究</a></dd>
          <dd><a href="/ccrs">自助评级</a></dd>
          <dd><a href="javascript:;" onclick="showmodel()">园区信息</a></dd>
          <dd><a href="javascript:;" onclick="showmodel()">专家信息</a></dd>
        </dl>
      </li>
    </ul>
    <div style="clear: both;"></div>
  </div>
  <div style="height: 70px;"></div>
  <!-- select区 -->
  <div class="layui-container" style="width: 100%;">
      <div class="describe">
        <form class="layui-form layui-form-pane" action="" method="post">
          <div class="layui-row">
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">algo：</label>
                <div class="layui-input-block">
                  <select name="algo" lay-verify="required"></select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">freq：</label>
                <div class="layui-input-block">
                  <select name="freq" lay-verify="required"></select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">vol：</label>
                <div class="layui-input-block">
                  <select name="vol" lay-verify="required"></select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">meta：</label>
                <div class="layui-input-block">
                  <select name="meta" lay-verify="required"></select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2">
              <div class="layui-form-item">
                <label class="layui-form-label">end：</label>
                <div class="layui-input-block">
                  <select name="end" lay-verify="required"></select>
                </div>
              </div>
            </div>
            <div class="layui-col-md2" style="float: right;">
              <button class="layui-btn" lay-button lay-filter="formDemo" type="button" style="padding: 0 120px;" onclick="FormSub()">确定</button>
            </div>
          </div>
        </form>
    </div>
  </div>
  <!-- 因子看板 -->
  <div class="layui-container" style="overflow: auto;text-align: right;width: 100%;position: relative;">
    <table class="layui-table Factor" width="100%" style="margin-bottom: 0;">
      <colgroup>
        <col width="150">
        <col width="200">
        <col>
      </colgroup>
      <thead>
        <tr>
          <th>因子看板</th>
          <!-- <th>000009.SZ</th>
          <th>000012.SZ</th>
          <th>000021.SZ</th>
          <th>000027.SZ</th>
          <th>000028.SZ</th> -->
          <th style="width: 5%;">
            <i class="layui-icon" onclick="changelist()" style="cursor: pointer;">换一换&#xe669;</i>
          </th>
        </tr> 
      </thead>
      <tbody>
        <tr>
          <td>净利润与营业总收入之比</td>
          <td>-3.64%</td>
          <td>2.13%</td>
          <td>1.60%</td>
          <td>0.96%</td>
          <td>0.015</td>
          <td>更多</td>
        </tr>
      </tbody>
    </table>
    <!-- 分页器 -->
    <div style="background-color: #fff;margin-bottom: 20px;text-align: center;">
      <div id="feather_page"></div>
    </div>
  </div>
  <div class="frame">
    <h3>标题</h3>
    <div style="margin-top: 10px;">
      <p><span>meta:</span><span id="f_meta">meta</span></p>
      <p><span>algo:</span><span id="f_algo">algo</span></p>
      <p><span>freq:</span><span id="f_freq">freq</span></p>
      <p><span>vol:</span><span id="f_vol">vol</span></p>
      <p><span>end:</span><span id="f_end">end</span></p>
    </div>
  </div>
  <!-- 图表 -->
  <div class="layui-container" style="width: 100%;">
    <div class="table_select">
      <form class="layui-row layui-col-space10 layui-form" action="" method="post">
        <div class="layui-col-md3">
          <div class="layui-form-item">
            <label class="layui-form-label">因子1</label>
            <div class="layui-input-block">
              <select name="x_axis" lay-verify="required" id="x_axis"></select>
            </div>
          </div>
        </div>
        <div class="layui-col-md3">
          <div class="layui-form-item">
            <label class="layui-form-label">因子2</label>
            <div class="layui-input-block">
              <select name="y_axis" lay-verify="required" id="y_axis"></select>
            </div>
          </div>
        </div>
        <div class="layui-col-md3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 200px;padding-top: 0;"><button type="button"  class="layui-btn">计算相关系数</button></label>
            <div class="layui-input-block" onclick="coe()">
              <input type="text" disabled class="layui-input coe_int" style="width: 200px;">
            </div>
          </div>
        </div>
        <div class="layui-col-md3">
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button type="button" class="layui-btn axis_btn" lay-button lay-filter="formDemo" style="padding: 0 100px;">确定</button>
            </div>
          </div>
        </div>
      </form>
      <!-- 图表显示区 -->
      <div id="graphic_show"></div>
    </div>
  </div>
  <!-- 底部 -->
  <div class="footer">
    <div class="layui-container">
      <div>
        <dl class="dl">
          <dt>关于</dt>
          <dd><a href="http://www.tafirt.org/about.html" target="_blank" rel="noopener noreferrer">关于我们</a></dd>
          <dd><a href="http://www.tafirt.org/coalize.html" target="_blank" rel="noopener noreferrer">加入我们</a></dd>
          <dd><a href="http://www.tafirt.org/contact.html" target="_blank" rel="noopener noreferrer">联系我们</a></dd>
        </dl>
        <dl class="dl">
          <dt>帮助</dt>
          <dd onclick="showmodel()">常见问题</dd>
          <dd onclick="showmodel()">API文档</dd>
        </dl>
        <dl class="dl">
          <dt>友情链接</dt>
          <dd><a href="http://www.ia.cas.cn/" target="_blank" rel="noopener noreferrer">中国科学院自动化研究所</a></dd>
          <dd><a href="http://www.ia.cas.cn/jgsz/kyxt/ZNGZ/" target="_blank" rel="noopener noreferrer">智能感知与计算研究中心</a></dd>
          <dd><a href="https://www.csc108.com/comOverView/introduce.jspx" target="_blank" rel="noopener noreferrer">中信建投证券</a></dd>
        </dl>
        <dl>
          <img src="../static/images/qrcode.png" alt="">
        </dl>
      </div>
    </div>
    <div style="clear: both;"></div>
  </div>
  <p style="color: #000000;text-align: center;">@2022 津icp备15002249号-6</p>
  <style>
    input,select{
      border: none;
    }
  </style>
  <!-- 弹框 -->
  <div class="mask"></div>
  <form class="model_f qr_login">
    <div class="model_logo">
      <img src="../static/images/logo.png" alt="">
      <span>TAFIRT</span>
    </div>
    <div class="model_title">
      验证码登录/注册
    </div>
    <div class="group">
      <select name="" id="sel" required>
        <option value="+86">+86</option>
        <option value="+86">中国+86</option>
        <option value="+86">中国香港特别行政区+852</option>
      </select>
      <input type="number" class="int iphone" required placeholder="手机号">
    </div>
    <div class="group">
      <input type="text" class="int graphical" required placeholder="获取验证码">
      <img src="" alt="">
    </div>
    <div class="group">
      <input type="text" class="int qrcode" required placeholder="验证码">
      <span>获取验证码</span>
    </div>
    <div class="group gologin">
      <button class="layui-btn layui-btn-fluid">登录</button><br/>
      <a href="javascript:;" class="" style="padding-bottom: 20px;" onclick="goreg()">密码登录 ></a>
    </div>
  </form>
  <form class="model_f pass_login">
    <div class="model_logo">
      <img src="../static/images/logo.png" alt="">
      <span>TAFIRT</span>
    </div>
    <div class="model_title">
      密码登录
    </div>
    <div class="group">
      <input type="number" class="int" required placeholder="手机/邮箱/用户名" style="width: 340px;">
    </div>
    <div class="group">
      <input type="password" class="int" required placeholder="密码" style="width: 340px;">
    </div>
    <div class="group">
      <input type="text" class="int qrcode" required placeholder="验证码">
      <img src="" alt="">
    </div>
    <div class="group gologin">
      <button class="layui-btn layui-btn-fluid">登录</button><br/>
      <a href="javascript:;" class="" style="padding-bottom: 20px;float: left;">忘记密码?</a>
      <a href="javascript:;" class="" style="padding-bottom: 20px;float: right;" onclick="gologin()">验证码登录/注册 ></a>
    </div>
  </form>
</body>

<script>
  $('.two_li').click(function(){
    $('.two_li dl').toggle()
  })
</script>
<script>
  layui.use(['form'], function(){
    var form = layui.form;
    $.ajax({
      type:'get',
      url:'/initform',
      success:function(data){
        for (const key in data) {
          let _html = '';
          for(var i = 0; i < data[key].length; i++){
            _html+= '<option value="'+data[key][i]+'">'+data[key][i]+'</option>'
          }
          $('select[name='+key+']').html('<option value="no">无</option>'+_html)
        }
        form.render();
      },
      error:function(err){
        console.log('wrr'+err)
        layer.msg('出错啦');
      }
    })
  })
</script>
<script>
  // 顶部条件查询
  function FormSub(){
    var algo = $('select[name="algo"]').val();
    var freq = $('select[name="freq"]').val();
    var vol = $('select[name="vol"]').val();
    var meta = $('select[name="meta"]').val();
    var end = $('select[name="end"]').val();

    // console.log(algo,freq,vol,meta,end);

    var _html = '';
    var _table_title = '';
    var _htmlecharts = '';
    layer.load(1)
    layui.use(['form'], function(){
      var form = layui.form;
      $.ajax({
        type:'post',
        url:'/formsub',
        data:{"algo":algo,"freq":freq,"vol":vol,"meta":meta,"end":end},
        success:function(data){
          console.log(data)
          var len_arr = Object.keys(data[Object.keys(data)[0]]);
          for(var i = 0; i < len_arr.length; i++){
            _table_title += '<th>'+len_arr[i]+'</th>'
          }
          _table_title = '<th>因子看板</th>'+_table_title+'<th style="width: 5%;"><i class="layui-icon" onclick="changelist()" style="cursor: pointer;">换一换&#xe669;</i></th>'
          for (const key in data) {
            var _tdhtml = '';
            for (const i in data[key]) {
              _tdhtml += '<td>'+data[key][i]+'</td>'
            }
            _html +=  '<tr>'+
                      '<td><a href="/details/'+key+'">'+key+'</a></td>'+
                        _tdhtml+
                        '<td><a href="/details/'+key+'">更多</a></td>'+
                      '</tr>'
          }
          $('.Factor thead').html(_table_title);
          $('.Factor tbody').html(_html);
          _html = '';
          _table_title = '';
          for (const key in data) {
            _htmlecharts += '<option value="'+key+'">'+key+'</option>';
          }
          // console.log(_htmlecharts)
          $('#y_axis').html(_htmlecharts);
          $('#x_axis').html(_htmlecharts);
          _htmlecharts = '';
          form.render();
          layer.closeAll('loading');
        },
        error:function(err){
          layer.msg('出错啦');
        }
      })
    })

  }
</script>
<script>
  var chartDom = document.getElementById('graphic_show');
  var myChart = echarts.init(chartDom);
  var option;

  option = {
    legend: {},
    tooltip: {},
    dataset: {
      source: [
        ['因子', '因子1', '因子2'],
        ['LSTM', 43.3, 93.7],
        ['GRU', 83.1, 55.1],
        ['TCN', 86.4, 82.5],
        ['CNN', 72.4,  39.1],
        ['TRANS', 22.4,  39.1],
        ['HAN', 32.4, 39.1]
      ]
    },
    xAxis: { type: 'category' },
    yAxis: {},
    // Declare several bar series, each will be mapped
    // to a column of dataset.source by default.
    series: [{ type: 'bar' }, { type: 'bar' }]
  };
  myChart.setOption(option);

// 计算系数
  function coe(){
    var x_axis;
    var y_axis;
    x_axis = $("select[name='x_axis']").val();
    y_axis = $("select[name='y_axis']").val();
    layer.load(1)
    $.ajax({
      type:'get',
      url:'/coefficient',
      data:{
        "x_axis":x_axis,
        "y_axis":y_axis
      },
      success:function(data){
        // console.log(data)
        $('.coe_int').val(data);
        layer.closeAll('loading');
      },
      error:function(err){
        console.log('wrr'+err)
        layer.msg('出错啦');
      }
    })
  }


  // 坐标查询
  $('.axis_btn').click(function(){
    var x_axis;
    var y_axis;
    var x_name;
    var y_name;
    x_axis = $("select[name='x_axis']").val();
    y_axis = $("select[name='y_axis']").val();
    // console.log(x_axis,y_axis);
    x_name = x_axis.split('-')[0]
    y_name = y_axis.split('-')[0]
    layer.load(1);
    $.ajax({
      type:'get',
      url:'/indexEcharts',
      data:{
        "x_axis":x_axis,
        "y_axis":y_axis
      },
      success:function(data){
        for (const key in data){
          data[key].unshift(x_name+'-'+y_name+key)
        }
        var datasets = {};
        datasets['source'] = data;
        option.dataset = datasets;
        option.series = [{ type: 'bar' }, { type: 'bar' }];
        // console.log(option)
        myChart.setOption(option);
        layer.closeAll('loading');
      },
      error:function(err){
        console.log('wrr'+err)
        layer.msg('出错啦');
      }
    })
  })
</script>
<script>
  layui.use(['laypage','form'], function(){
    var laypage = layui.laypage;
    var form = layui.form;
    let _html = '';
    var _htmlecharts = '';
    var _table_title = '';
    $.ajax({
      type:'get',
      url:'/tol_page',
      success:function (data) {
        // console.log(data)
        //执行一个laypage实例
        laypage.render({
          elem: 'feather_page' //注意，这里的 test1 是 ID，不用加 # 号
          ,count: Number(data) //数据总数，从服务端得到
          ,limit:15 //限制煤业条数
          ,jump:function(obj,first){
            // console.log(obj.limit); //得到每页显示的条数
            // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
            $.ajax({
              type:'get',
              data:{"page":obj.curr},
              url:'/page',
              success:function(data){
                data = JSON.parse(data);
                var len_arr = Object.keys(data[Object.keys(data)[0]]);
                for(var i = 0; i < len_arr.length; i++){
                  _table_title += '<th>'+len_arr[i]+'</th>'
                }
                _table_title = '<th>因子看板</th>'+_table_title+'<th style="width: 5%;"><i class="layui-icon" onclick="changelist()" style="cursor: pointer;">换一换&#xe669;</i></th>'
                // console.log(data)
                for (const key in data) {
                  // console.log(key)
                  var _tdhtml = '';
                  for (const i in data[key]) {
                    _tdhtml += '<td>'+data[key][i]+'</td>'
                  }
                  _html +=  '<tr>'+
                            '<td><a href="/details/'+key+'">'+key+'</a></td>'+
                              _tdhtml+
                            '<td><a href="/details/'+key+'">更多</a></td>'+
                            '</tr>'
                }
                $('.Factor thead').html(_table_title);
                $('.Factor tbody').html(_html);
                _html = '';
                _table_title = '';

                for (const key in data) {
                  _htmlecharts += '<option value="'+key+'">'+key+'</option>';
                }
                // console.log(_htmlecharts)
                $('#y_axis').html(_htmlecharts);
                $('#x_axis').html(_htmlecharts);
                _htmlecharts = '';
                form.render();
              },
              error:function (err) {
                layer.msg('出错啦');
              }
            })
          }
        });
      },
      error:function(err){
        console.log('wrr'+err)
        layer.msg('出错啦');
      }
    })
  });
  // 换一换
  function changelist(){
    var _table_title = '';
    var _html = '';

    layer.load(1);
    $.ajax({
      type:'get',
      url:'/changeList',
      data:{},
      success:function(data){
        // console.log(data)
        var len_arr = Object.keys(data[Object.keys(data)[0]]);
        for(var i = 0; i < len_arr.length; i++){
          _table_title += '<th>'+len_arr[i]+'</th>'
        }
        _table_title = '<th>因子看板</th>'+_table_title+'<th style="width: 5%;"><i class="layui-icon" onclick="changelist()" style="cursor: pointer;">换一换&#xe669;</i></th>'
        for (const key in data) {
          var _tdhtml = '';
          for (const i in data[key]) {
            _tdhtml += '<td>'+data[key][i]+'</td>'
          }
          _html +=  '<tr>'+
                    '<td><a href="/details/'+key+'">'+key+'</a></td>'+
                      _tdhtml+
                      '<td><a href="/details/'+key+'">更多</a></td>'+
                    '</tr>'
        }
        $('.Factor thead').html(_table_title);
        $('.Factor tbody').html(_html);
        _html = '';
        _table_title = '';
        layer.closeAll('loading');
      },
      error:function(err){
        console.log('wrr'+err)
        layer.msg('出错啦');
      }
    })
  }
  </script>

<script>
  $(function(){
    var modeldata;
    $.ajax({
      type:'get',
      url:'/indexdes',
      success:function(data){
        // console.log(data);
        modeldata = data;
      },
      error:function(err){}
    })
    $('.Factor').on('mouseenter','td',function(e){
      // console.log(e)
      var first = $(this).parent().children()[0].innerText;
      $('.frame h3').html(modeldata[first]['title']);
      $('#f_meta').html(modeldata[first]['meta']);
      $('#f_algo').html(modeldata[first]['algo']);
      $('#f_freq').html(modeldata[first]['freq']);
      $('#f_vol').html(modeldata[first]['vol']);
      $('#f_end').html(modeldata[first]['end']);
      $('.frame').show()
    })
    $('.Factor').on('mousemove','td',function(e){
      $('.frame').css({"left":e.pageX+20,"top":e.pageY+20})
    })
    $('.Factor').on('mouseout','td',function(e){
      $('.frame').hide();
    })
  })
</script>
<script>
layui.use(['util'],function(){
  var util = layui.util;
    //返回顶部
    util.fixbar({
      bar1: false
      ,bar2: false
      ,css: {right: 10, bottom: 30}
      ,bgcolor: 'rgb(231, 76, 60)'
    });
});

$('.mask').click(function(){
  $('.pass_login,.qr_login').hide();
  $(this).hide();
})
function showmodel(){
  $('.qr_login,.mask').show();
}
function goreg(){
  $('.pass_login').show();
}
function gologin(){
  $('.pass_login').hide();
  $('.qr_login').show();
}
</script>
</html>